package com.rljk.common.result;

public class CodeMsg {
	
	private int code;
	private String msg;
	
	//通用的错误码
	//通用的错误码0X
	public static CodeMsg SERVER_ERROR = new CodeMsg(500, "服务端异常");
	public static CodeMsg SUCCESS = new CodeMsg(200, "success");
	public static CodeMsg EMPTY = new CodeMsg(20, "返回空值");
	public static CodeMsg PARAM_LACK = new CodeMsg(30, "请求参数不完整");
	public static CodeMsg LOGIN_ERROR = new CodeMsg(40, "用户名或密码错误");
	public static CodeMsg FKEY_FAIL = new CodeMsg(50, "FKEY校验失败");
	public static CodeMsg ENUM_NOT_FIND = new CodeMsg(60, "么有找到对应的枚举");
	public static CodeMsg BIND_ERROR = new CodeMsg(500101, "参数校验异常：%s");
	public static CodeMsg SUBMIT_REPEAT = new CodeMsg(500102, "请不要重复提交");
	//登录模块 5002XX
	public static CodeMsg TOKEN_ERROR = new CodeMsg(500210, "TOKEN不存在或者已经失效");
	public static CodeMsg MOBILE_NOT_EXIST = new CodeMsg(500214, "手机号不存在");
	public static CodeMsg CODE_ERROR = new CodeMsg(500216, "验证码错误");
	public static CodeMsg SENDMSG_ERROT = new CodeMsg(500217, "请不要重复发送验证码");
	public static CodeMsg LOGIN_SUCCESS = new CodeMsg(500218, "登录成功");
	public static CodeMsg LOGINORREGISTER_ERROR = new CodeMsg(500219, "COOKIE为空");

	public static CodeMsg REGIST_SUCCESS = new CodeMsg(500220, "注册成功");
	public static CodeMsg REGIST_ERROT = new CodeMsg(500221, "注册账号已存在");
	public static CodeMsg RESET_SUCCESS = new CodeMsg(500222, "重置成功");
	public static CodeMsg RESET_ERROT = new CodeMsg(500223, "两次密码不一致");

	//财富模块 5003XX
	public static CodeMsg WEALTH_RESET_ERROT = new CodeMsg(500301, "您已经收取过了");
	
	//订单模块 5004XX
	public static CodeMsg ORDER_NOT_EXIST = new CodeMsg(500400, "订单不存在");
	
	//秒杀模块 5005XX
	public static CodeMsg MIAO_SHA_OVER = new CodeMsg(500500, "商品已经秒杀完毕");
	public static CodeMsg REPEATE_MIAOSHA = new CodeMsg(500501, "不能重复秒杀");
	public static CodeMsg MIAOSHA_FAIL = new CodeMsg(500502, "秒杀失败");
	
	
	private CodeMsg( ) {
	}
			
	private CodeMsg( int code,String msg ) {
		this.code = code;
		this.msg = msg;
	}
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	
	public CodeMsg fillArgs(Object... args) {
		int code = this.code;
		String message = String.format(this.msg, args);
		return new CodeMsg(code, message);
	}

	@Override
	public String toString() {
		return "CodeMsg [code=" + code + ", msg=" + msg + "]";
	}
	
	
}
